package com.hopu.aop.proxy.jdk;


import com.hopu.aop.proxy.CellphoneFactory;
import com.hopu.aop.proxy.CellphoneSales;
import com.hopu.aop.proxy.computer.ComputerFactory;
import com.hopu.aop.proxy.computer.ComputerSales;

public class JdkProxyTest {

    public static void main(String[] args) {
        //被代理对象
        CellphoneSales cellphoneFactory = new CellphoneFactory();
        ComputerSales computerFactory = new ComputerFactory();
        //创建动态代理对象
        ProductProxy productProxy = new ProductProxy();
        //通过动态代理生成代理对象
        CellphoneSales cellphoneSales  = (CellphoneSales) productProxy.createProxy(cellphoneFactory);
        cellphoneSales.sellCellphone("小米18");

        ComputerSales computerSales = (ComputerSales) productProxy.createProxy(computerFactory);
        computerSales.sellComputer("戴尔");

        System.out.println(computerSales.getClass());
    }
}
